﻿package mortal.game.scene3D.display3d.text3d.staticText3d.action
{
    import flash.geom.*;

    public class Action1MoveFun extends ActionMoveBase
    {
        private const _V:Number = 25;
        private const _A:Number = 4;
        private const _lastV:Number = 5;
        private const _moveTime:int = 3;
        private const _midTime:int = 9;
        private const _waitTime:int = 21;
        private const _randomMoveTime:int = 41;
        private const _lastWaitTime:int = 50;
        private const _alphaTime:int = 60;
        private const _totalTime:int = 60;
        private const addScale:int = 5;
        private const subScale:int = 10;
        private const totalFrame:int = 15;
        private var _curOffY:int = 0;
        private var _curOffX:int = 0;
        private var _alpha:Number = 0.99;
        private var _scale:int = 100;
        private var _Ax:Number;
        private var _Ay:Number;
        private var _Vx:Number;
        private var _Vy:Number;
        private var _LVx:int;
        private var _LVy:int;
        private var _flag:int = 1;

        public function Action1MoveFun()
        {
            return;
        }// end function

        override public function set vo(param1:ActionVo) : void
        {
            super.vo = param1;
            var _loc_2:* = Math.atan2(param1.start2d_y - param1.end2d_y, param1.end2d_x - param1.start2d_x);
            var _loc_3:* = Math.cos(_loc_2);
            var _loc_4:* = Math.sin(_loc_2);
            this._Ax = this._A * _loc_3;
            this._Ay = this._A * _loc_4;
            this._Vx = this._V * _loc_3;
            this._Vy = this._V * _loc_4;
            _loc_2 = param1.randomValue * 90 - 45;
            _loc_2 = this._flag * _loc_2 / 180 * Math.PI + Math.PI / 2;
            var _loc_5:* = Math.cos(_loc_2);
            var _loc_6:* = Math.sin(_loc_2);
            this._LVx = Math.round(_loc_5 * this._lastV);
            this._LVy = Math.round(_loc_6 * this._lastV);
            return;
        }// end function

        override public function update(param1:int, param2:Vector3D) : Boolean
        {
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            if (param1 > this._totalTime)
            {
                this._curOffY = 0;
                this._curOffX = 0;
                this._alpha = 0.99;
                this._scale = 100;
                return false;
            }
            if (changeScale)
            {
                if (param1 <= this.addScale)
                {
                    _loc_3 = 100 + 150 * param1 / this.addScale;
                }
                else if (param1 <= this.totalFrame)
                {
                    _loc_3 = 250 - 150 * (param1 - this.addScale) / this.subScale;
                }
                else
                {
                    _loc_3 = 150;
                }
                this._scale = this._scale + (_loc_3 - this._scale) / 5;
            }
            if (param1 <= this._moveTime)
            {
                this._curOffX = this._Vx * param1;
                this._curOffY = this._Vy * param1;
            }
            else if (param1 <= this._midTime)
            {
                _loc_4 = param1 - this._moveTime;
                _loc_4 = _loc_4 * (0.5 * _loc_4);
                this._curOffX = this._Vx * param1 - this._Ax * _loc_4;
                this._curOffY = this._Vy * param1 - this._Ay * _loc_4;
            }
            else if (param1 <= this._waitTime)
            {
            }
            else if (param1 <= this._randomMoveTime)
            {
                this._curOffX = this._curOffX + this._LVx;
                this._curOffY = this._curOffY + this._LVy;
            }
            else if (param1 <= this._lastWaitTime)
            {
            }
            else if (param1 <= this._alphaTime)
            {
                this._curOffX = this._curOffX + this._LVx;
                this._curOffY = this._curOffY + this._LVy;
                this._alpha = (this._totalTime - param1) / 10 * 0.7 + 0.29;
            }
            param2.x = this._curOffX;
            param2.y = this._curOffY;
            param2.z = this._alpha + this._scale;
            return true;
        }// end function

    }
}
